<template>
	<view class="brand-page">
		<view class="topSafe" :style="'height:'+topSafe+'px'"></view>
		<view class="title-w-box" :style="{paddingTop: topSafe + 'px', opacity: opacity}">
		</view>
		<view id="past0" class="title-box" :style="{paddingTop: topSafe + 'px'}">
			<view class="main">品牌馆</view>
		</view>
		

		<view class="slider-box">
			<view 
				class="item" 
				v-for="(item, index) in slideList" 
				:key="index"
				@click="goDetail(item)"
			>
				<view class="main-box">
					<view class="top">
						<view class="new" v-if="item.dis_old == 100">全新</view>
						<view class="right">
							<image src="../../static/images/icon/deposit.png"></image>
							<text>信用免押</text>
						</view>
					</view>
					<view class="title o-ellipsis">{{ item.store_name }}</view>
					<view class="tabs">
						<view v-for="(item, index) in item.StoreProductLabel">
							<view :class="index == 0 ? 'jx' : 'bt'" class="tab jx">{{item}}</view>
						</view>
						<!-- <view class="tab jx" v-if="item.StoreProductLabel.length > 1">{{ item.StoreProductLabel[0] }}</view> -->
						<!-- <view class="tab bt" v-if="item.StoreProductLabel.length > 2">{{ item.StoreProductLabel[1] }}</view> -->
					</view>
					<view class="advantage">
						<text>顺丰包邮</text>
						<!-- <text>租完归还</text> -->
					</view>
					<view class="b-pic">
						<image :src="item.image"></image>
					</view>
				</view>
				
				<view class="i-bottom">
					<view class="price">¥ <text>{{ item.min_day_price }}</text><text class="day">/天</text></view>
					<view class="i-btn">免押租</view>
				</view>
			</view>
		</view>
		<brand-special-session dataType="brand" :list="list"></brand-special-session>
		
		<u-empty
		    mode="list"
			v-if="!list.length"
			text="暂无数据..."
			textSize="28"
			iconSize="120"
		>
		</u-empty>
		<u-loadmore 
			marginTop="20"
			fontSize="28"
			v-if="list.length"
			:status="loadStatus" 
			loading-text="努力加载中" 
			loadmore-text="轻轻上拉" 
			nomore-text="没有更多啦~" 
		/>
	</view>
</template>

<script>
	import brandSpecialSession from './components/brand-special-session';
	import { brandProductList } from "@/api/brandHall.js"
	export default {
		components: {
			brandSpecialSession
		},
		data() {
			return {
				opacity: 0,
				topSafe: 0,
				currentPage: 1,
				slideList: [], // 滑动列表
				list: [], // 列表
				loadStatus: "nomore", // load 状态
			}
		},
		onLoad() {
			// uni.setNavigationBarColor({
			//     frontColor: '#ffffff',
			//     backgroundColor: '#ff0000',
			//     animation: {
			//         duration: 400,
			//         timingFunc: 'easeIn'
			//     }
			// })
			// if(uni.getSystemInfoSync().safeAreaInsets){
			// 	this.topSafe = uni.getSystemInfoSync().safeAreaInsets.top
			// }
			
			uni.getSystemInfo({
				success: (e) => {
					this.topSafe = e.statusBarHeight //状态栏高度
				}
			})
			
			this.getBrandProductList();
		},
		
		methods: {
			/* 跳转详情 */
			goDetail(e) {
				uni.navigateTo({
					url: `/pages/goods_details/index?id=${e.id}`
				})
			},
			/* 获取品牌馆数据 */
			getBrandProductList() {
				brandProductList({
					page: this.currentPage,
					limit: 20,
				}).then(res => {
					this.list = [...this.list, ...res.data.list];
					this.slideList = res.data.rec_list;
					if(res.data.list < 20) {
						this.loadStatus = "nomore"
					}else {
						this.loadStatus = "loadmore"
					}
				})
			},
			/* 触底 */
			onReachBottom() {
				if(this.loadStatus == "nomore") return
				this.loadStatus = "loading";
				this.currentPage ++;
				this.getBrandProductList();
			},
			onPageScroll(res) {
				var that = this,
					scrollY = res.scrollTop;
				var opacity = scrollY / 200;
				opacity = opacity > 1 ? 1 : opacity;
				that.$set(that, 'opacity', opacity);
			},
		},
	}
</script>

<style lang="scss">
	page { background-color: #F5F7FA; }
	.brand-page {
		background-image: url('https://wap.yqjy8.vip/uploads/attach/2023/05/20230516/2b902495f4a5ad7b2b900ba1fe426c50.png');
		background-repeat: no-repeat;
		background-size: 100%;
		background-color: #F5F7FA;
		padding-bottom: 40rpx;
		
		
		.title-w-box {
			position: fixed;
			top: 0;
			width: 100%;
			z-index: 277;
			display: flex;
			align-items: center;
			padding-left: 80rpx;
			background-color: #fff;
			height: 170rpx;
		}
		
		.title-box {
			position: fixed;
			top: 0;
			width: 100%;
			z-index: 277;
			display: flex;
			align-items: center;
			padding-left: 80rpx;
			height: 170rpx;
			.main {
				font-size: 32rpx;
				font-weight: bold;
				color: #1F1F1F;
			}
		}
		
		.top-head {
			display: flex;
			align-items: center;
			
			.page-title {
				margin-left: 34rpx;
				font-size: 32rpx;
				font-weight: bold;
				color: #FFFFFF;
			}
		}
	
		.slider-box {
			display: flex;
			overflow-x: scroll;
			width: auto;
			flex-direction: row;
			flex-shrink: 0;
			flex-wrap: nowrap;
			padding: 0 24rpx;
			padding-top: 360rpx;
			padding-top: calc(360rpx - constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
			padding-top: calc(360rpx - env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
		
			
			.item {
				width: 480rpx;
				border-radius: 16rpx;
				border: 2rpx solid #FFFFFF;
				background-color: #fff;
				
				~.item {
					margin-left: 24rpx;
				}
				
				.main-box {
					padding: 24rpx 24rpx 0 24rpx;
				}
				
				.top {
					display: flex;
					justify-content: space-between;
					
					.new {
						min-width: 64rpx;
						padding: 0 4rpx;
						height: 40rpx;
						background: linear-gradient(180deg, #FF9D5C 0%, #FF7847 100%);
						border-radius: 20rpx;
						font-size: 24rpx;
						font-weight: bold;
						color: #FFFFFF;
						line-height: 40rpx;
						text-align: center;
					}
					
					.right {
						display: flex;
						align-items: center;
						height: 32rpx;
						background: rgba(41,126,255,0.08);
						border-radius: 4rpx;
						padding: 0 6rpx;
						
						image {
							width: 22rpx;
							height: 24rpx;
						}
						
						text {
							font-size: 24rpx;
							font-weight: 400;
							color: #297EFF;
							margin-left: 4rpx;
						}
					}
				}
			
				.title {
					margin-top: 24rpx;
					font-size: 36rpx;
					font-weight: bold;
					color: #292929;
					line-height: 36rpx;
				}
			
				.tabs {
					margin-top: 24rpx;
					display: flex;
					
					.tab {
						padding: 0 8rpx;
						height: 40rpx;
						line-height: 40rpx;
						border-radius: 4rpx;
						font-size: 24rpx;
						font-weight: 400;
						text-align: center;
						margin-right: 10rpx;
						
						&.jx {
							color: #FF9147;
							background: rgba(255,145,71,0.08);
						}
						
						&.bt {
							color: #FF3D1F;
							background: rgba(255,96,71,0.08);
						}
						
						&~.tab {
							margin-left: 12rpx;
						}
					}
				}
			
				.advantage {
					margin-top: 24rpx;
					display: flex;
					
					text {
						position: relative;
						font-size: 24rpx;
						font-weight: 400;
						color: #999999;
						line-height: 24rpx;
						
						~text {
							margin-left: 24rpx;
							
							&:before {
								content: " ";
								display: block;
								position: absolute;
								left: -12rpx;
								top: 6rpx;
								z-index: 2;
								width: 2rpx;
								height: 16rpx;
								background: #EBEBEB;
							}
						}
					}
				}
			
				.b-pic {
					margin-top: 24rpx;
					width: 432rpx;
					height: 432rpx;
					border-radius: 16rpx;
					overflow: hidden;
					
					image {
						width: 432rpx;
						height: 432rpx;
					}
				}
			
				.i-bottom {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 0 24rpx;
					width: 100%;
					height: 88rpx;
					background: #F5F7FA;
					border-radius: 0rpx 0rpx 16rpx 16rpx;
					
					.price {
						font-size: 40rpx;
						font-weight: bold;
						color: #FF1F2E;
						vertical-align: text-bottom;
						
						text {
							margin-left: 8rpx;
							font-size: 56rpx;
						}
						
						.day {
							margin-left: 8rpx;
							font-size: 24rpx;
							font-weight: normal;
							color: #FF1F2E;
						}
					}
					
					.i-btn {
						width: 148rpx;
						height: 60rpx;
						line-height: 60rpx;
						text-align: center;
						background: rgba(57,204,194,0.08);
						border-radius: 30rpx;
						font-size: 28rpx;
						font-weight: bold;
						color: #39CCC2;
					}
				}
			}
		}
	}
</style>